home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
cad
/
acadfont.zip
/
MAKEFONT.DOC
< prev
next >
Wrap
Text File
|
1993-02-19
|
8KB
|
140 lines
From CADENCE Magazine May, 1991
Head: Make Your Own
Sub: Create Fonts with MAKEFONT.LSP
by Brad Halls
MAKEFONT.LSP (Listing 1) is an AutoLISP program designed to aid
in creating and customizing fonts for AutoCAD. The program is
designed so that anyone can customize fonts without having a
thorough knowledge of AutoCAD shape files. MAKEFONT.LSP also
handles the frustrating process of generating the actual shape
code from the creator's shoulders. To do this, MAKEFONT.LSP
prompts the user through the description of a character and keeps
track of pen movements, drawing modes, and the number of bytes
needed to describe the character in AutoCAD's SHP file format.
There are five steps needed to run the program and create a
custom font.
CREATING THE DRAWING
(Note: see included makefont.dxf.)
Grid size is the first thing to consider when creating a new
font. I found that a 50 x 50 grid works well, but the base size
is really arbitrary. In general, the more detailed the font, the
more accuracy needed to define it and hence the larger the grid.
Once the size is decided, the drawing limits should be set to
match the grid.
Next, the units and snap need to be set so that the program will
write integer values to the SHP file. Call up the Units command
and set the units to "decimal" (option 2), with zero places after
the decimal point. The snap should be on and set to 1. The screen
coordinates should be on and displaying integer values.
It is a good idea to set up a view slightly larger than your
grid, so the entire character can still be seen if you decide to
go outside the limits (zoom .8x should do it). Now, turn on the
grid, save the view, and end the drawing.
DESIGNING THE CHARACTER SET
Now that the drawing grid is set up, you should be ready to lay
out individual characters in the font. Fortunately, it isn't
necessary to complete the entire character set in order to
compile the font, so it is possible to start with the less-
complicated characters and compile them first.
Since the program works by digitizing each character to create
the SHP file, no true arcs are allowed. You can, however, achieve
pretty good results by using a series of short line segments as I
have shown here for the number 2 (Figure 1). Of course, the
characters don't need to be drawn out at all_they can be
digitized from scratch. This, however, would be more difficult.
Remember, the more vectors (points) it takes to describe a font,
the more time will be needed to display it, so don't get to
detailed unless you are prepared to wait for many of long, slow
regens.
When creating a character set, it is also a good idea to take
advantage of AutoCAD's subshape feature whenever possible. Any
character can be used as a subshape for another character, so it
is possible to save time and file space by using subshapes
creatively. One example is using the existing digits 0 through 9
as subshapes to create the fractional characters 1/16 through
15/16. The keys that the fractions are assigned to are up to you.
The lowercase keys "qwerty" and "asdfg" work well if you usually
use caps on your drawings.
Another advantage of creating a custom font is that frequently
used characters that are are not standard ASCII, such as the
"plate" and "center line" symbols used by many AE firms, can be
easily added and assigned to any key available. After each
character is completed to your satisfaction, make a block of it
to be digitized later.
BEGINNING A PROTOTYPE
FONT FILE
Before a font can be compiled, a special shape number 0 that
contains information about the font name, size, and text
orientation must be added. This should be the first entry in the
SHP file, followed by the codes for a space (ASCII 32) and a line
feed (ASCII 10). For a 50 x 50 grid, the first three entries
should look something like this: (see accompanying template.shp).
Copy this file and rename it to whatever you want to call your
font, then adjust the sizes accordingly.
*0,4,fontname
50,0,2,0
*32,5,space
2,8,(50,0),0
*10,5,line_feed
2,8,(0,-75),0
These lines of code (or something similar) need to be written
into a file with an SHP extension and placed in the AutoCAD root
directory so that the character descriptions from MAKEFONT.LSP
can be appended to it later.
DEFINING A CHARACTER
Now you are ready to begin digitizing the characters you have
made and writing their descriptions to the SHP file. Call up the
MAKEFONT.DWG and insert the first character block. Load the
MAKEFONT.LSP program and follow the instructions from there.
Figure 1 shows the description process for a number 2. Start out
by picking (0,0) for the origin and then typing "U" (for pen up).
Pick point number 2, and type "S" to start the continuous pen
down (or CPD) mode. Now pick continuous points along the
character path through point number 3. Type "E" to exit CPD mode
and "U" to raise the pen. Pick point number 4 and type "D" to
lower the pen, then pick point number 5. Type "U" and pick the
point (50,50). The character is now complete, so type a "Q" to
quit the description process. Note that the last point of one
character is the insertion point for the next, so if the "2"
would have used the entire 50 x 50 limits, the last point
digitized would have been about (60,0) instead of (50,0).
The program will now ask if you want to write the description to
a file. Respond with a "y," and MAKEFONT.LSP will prompt you for
the name of the SHP file created in step 3. Type the name
(without the SHP extension). Next you will be prompted for the
ASCII code and a short description of your character. The ASCII
codes for the keyboard are listed on page 387 of the AutoCAD
manual. The description (not the one provided by the program but
by you) should be short and contain no spaces or uppercase
letters. Autodesk uses "uca" for an uppercase "A," but something
like "upper_case_a" will also work and may be more readable.
COMPILING AND TESTING THE FONT
After the character is finished, end the MAKEFONT.DWG and type
"7" at the AutoCAD main menu to compile your font. Now go back
into that drawing or start a new one and create a style (test,
for example) that utilizes the new font. If all goes well, it
should be possible to create a fairly large character set in a
short amount of time. Compilation errors for shape files are
sometimes difficult to find, so be patient and consult appendix
B.7 of the AutoCAD Reference Manual for further information.
Compile and test your font often as new letters are created so
that you will have a good idea of where to find any problems that
may arise. One hint is to watch for trailing blanks at the end of
lines or a missing return at the end of the SHP file. Keep your
favorite word processor handy for debugging and have fun with it.
Good Luck! @
Brad Halls is a CAD designer and programmer for Ruby &
Associates, P.C. in Southfield, Michigan.